Skip to content

Read the Google Advertising ID on every call, waiting by default up to 100 ms - #62

Open
jrosendahl-opt wants to merge 3 commits into
masterfrom
fix/gaid-read-per-call
Open

jrosendahl-opt wants to merge 3 commits into
masterfrom
fix/gaid-read-per-call

Conversation

@jrosendahl-opt

@jrosendahl-opt jrosendahl-opt commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Why

The SDK read the Google Advertising ID (GAID) once, when an instance was created, and kept it in a companion object shared by every instance:

  • A user who reset their ID or opted out mid-session kept being sent the old ID until the process restarted.
  • An instance created with skipAdvertisingIdDetection = true still sent a GAID an earlier instance had read.
  • identify and targeting waited for that first read behind a 3 second timeout that couldn't actually interrupt the blocking getAdvertisingIdInfo().

Google's guidance is to call getAdvertisingIdInfo() each time the ID is needed and not to cache it, and the Play ads policy requires respecting the user's opt-out and reset. The iOS SDK already reads the IDFA on each call.

The SDK read the GAID once when an instance was created and kept it in a
companion object shared by every instance, so a reset or opt-out was
ignored until the process restarted, and an instance created with
skipAdvertisingIdDetection still sent a GAID an earlier instance read.
identify and targeting also waited for that read behind a 3 second
timeout that couldn't interrupt the blocking getAdvertisingIdInfo().

Google says to call getAdvertisingIdInfo() each time the ID is needed and
not to cache it. identify and targeting now read the GAID and the opt-out
flag on every call, like the iOS SDK reads the IDFA, waiting at most
OptableConfig.advertisingIdTimeoutMs (default 100 ms) before sending the
call without it. Zero or less means don't wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jrosendahl-opt
jrosendahl-opt requested review from a team as code owners November 10, 2026 01:38
It was an internal val, so an app had to create a new OptableConfig and
OptableSDK when the user granted or withdrew consent for the advertising
ID. Make it a public var, like origin and consents and like the iOS SDK;
since the GAID is now read on every call, a change applies from the next
call. Both advertising ID settings are @volatile, as calls read them on a
background thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jrosendahl-opt added a commit that referenced this pull request Nov 10, 2026
Match #62: every identify and targeting call reads the GAID (never
cached), waiting up to advertisingIdTimeoutMs (100 ms by default), and
skipAdvertisingIdDetection can be changed at any time, applying from the
next call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A wait of zero or less skipped reading the GAID, so no ID could be
added. Raise any value below 1 ms to 1 ms instead: reading the GAID
always takes some time, typically tens of milliseconds depending on
the device, which the docs now say. skipAdvertisingIdDetection is the
way to never add it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jrosendahl-opt added a commit that referenced this pull request Nov 11, 2026
Match #62: advertisingIdTimeoutMs is at least 1 ms, so zero no longer
means the GAID is not added, and reading the GAID typically takes tens
of milliseconds depending on the device. skipAdvertisingIdDetection is
the way to never add it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jrosendahl-opt jrosendahl-opt changed the title Read the Google Advertising ID on every call, waiting up to 100 ms Read the Google Advertising ID on every call, waiting by default up to 100 ms Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant